package com.example.mobile2121606109ycg0407;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivityTip7 extends AppCompatActivity {

    private EditText edtTxtMain7Num;
    private TextView tvMain7Result;
    private TextView tvMain7Result2;
    private TextView tvMain7Result3;
    private Button btnMain7Result;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_tip7);
        initView();

        btnMain7Result.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //获取输入的五位整数
                String num = edtTxtMain7Num.getText().toString();
                //输出位数
                tvMain7Result.setText(String.valueOf(num.length()));
                //分别输出每一位数字
                char[] chars = num.toCharArray();
                tvMain7Result2.setText(String.valueOf(chars));
                //逆序输出
                StringBuffer sb=new StringBuffer(num);
                tvMain7Result3.setText(sb.reverse());
            }
        });
    }

    private void initView() {
        edtTxtMain7Num = (EditText) findViewById(R.id.edtTxtMain7_Num);
        tvMain7Result = (TextView) findViewById(R.id.tvMain7_Result);
        tvMain7Result2 = (TextView) findViewById(R.id.tvMain7_Result2);
        tvMain7Result3 = (TextView) findViewById(R.id.tvMain7_Result3);

        btnMain7Result = (Button) findViewById(R.id.btnMain7_Result);
    }
}